#'
#' @TODO 单细胞通路富集热图
#' @title 单细胞通路富集热图
#' @description 
#' @param SeuratObj 
#' @param GeneLst 背景基因集 
#' @param GroupInfor 热图分组信息，一般是细胞分类 
#' @param ColorUsed 分组颜色 
#' @param od 结果输出路径 
#' @param w 宽 
#' @param h 高
#' @param FileName 生成的文件名字
#' @export 
#' @author *WYK*
SCssGSEA <- \(SeuratObj = scRNA_epi, GeneLst = pathway, GroupInfor = "EpithelialCell",
    ColorUsed = scales::hue_pal()(5), od = file.path(out_home, "/out/SC2/scRNA_EPI/"), w = 5, h = 7.5, FileName = "hallmark_nes"){
    ssgsea_score <- GSVA::gsva(
        expr = SeuratObj@assays$RNA@counts,
        gset.idx.list = pathway,
        method = "ssgsea",
        verbose = T,
        kcdf = "Poisson",
        parallel.sz = 20
    ) %>% as.data.frame()

    ssgsea_score <- ssgsea_score %>%
        rownames_to_column("pathway") %>%
        as_tibble() %>%
        pivot_longer(-pathway, names_to = "cell", values_to = "score")

    cell_group <- SeuratObj@meta.data %>%
        select(get0(GroupInfor)) %>%
        rownames_to_column("cell")

    dat <- inner_join(ssgsea_score, cell_group) %>%
        group_by(get0(GroupInfor), pathway) %>%
        mutate(score_mean = median(score)) %>%
        select(-cell, -score) %>%
        distinct() %>%
        ungroup()

    dat <- dat %>%
        pivot_wider(names_from = get0(GroupInfor), values_from = score_mean) %>%
        as.data.frame() %>%
        column_to_rownames("pathway")

    group_infor <- data.frame(sample = colnames(dat), EpithelialCell = colnames(dat)) %>%
        column_to_rownames("sample")

    source("/Pub/Users/wangyk/Project_wangyk/Codelib_YK/some_scr/Heatmap_manul.R")
    a <- Heatmap_manul(
        data_input = dat, color_used = ColorUsed, group_infor = group_infor, Colored_OtherInfor = F,
        saveplot = T, output_dir = od,
        var_name = FileName, width_used = w, height_used = h, heatmap_name = "Scaled NES",
        cluster_name = NULL, show_rownames = T, DoWilcox.test = F, rownames_fontsize = 7
    )
}